<template>
  <div>
    <el-dialog
      title="提示"
      :visible.sync="isShow"
      width="30%"
      @close="closeEvent"
    >
      <span>
        <i class="el-icon-warning"></i>
        您确认要{{
          pubData.publishState === 1 ? '下架' : '上架'
        }}这道题吗?</span
      >
      <template #footer class="dialog-footer">
        <div style="text-align: right">
          <el-button @click="isShow = false" size="mini">取 消</el-button>
          <el-button type="primary" @click="submit" size="mini"
            >确 定</el-button
          >
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script>
import { choicePublish } from '@/api/hmmm/questions.js'
export default {
  name: 'publishBtn',
  props: ['pubData'],
  data () {
    return {
      isShow: false
    }
  },
  created () {},
  computed: {},
  methods: {
    closeEvent () {
      this.isShow = false
    },
    async submit () {
      await choicePublish({
        id: this.pubData.id,
        publishState: { 1: 0, 0: 1, 2: 1 }[this.pubData.publishState]
      })
      this.closeEvent()
      this.$emit('getData')
    }
  }
}
</script>
<style lang="scss" scoped>
i {
  color: #e6a23c;
  margin-right: 5px;
  font-size: 18px;
}
</style>
